//
//  AppProEmailTFView.swift
//  XiaoweHearingAid
//
//  Created by Riven on 2023/4/7.
//

import UIKit

class AppProEmailTFView: AppProTextFieldBaseView {
    
    override var maxCharacterCount: Int {
        80
    }
    
    override var kAlphaNum: String {
//        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@"
        ""
    }
    
    var isEmailOk: Bool = false

    override func addSubViews() {
        super.addSubViews()
        
//        titleLb.isHidden = true
//        button.setImage(R.image.eyeOff(), for: .normal)
//        button.setImage(R.image.eyeOn(), for: .selected)
        
        button.isHidden = true
        
        textField.placeholder = "请输入邮箱"
        textField.setPlaceHolderTextColor(placeHolderTextColor)
        
        textField.clearButtonMode = .never
        
//        textField.isSecureTextEntry = true
        textField.keyboardType = .emailAddress
        
        textField.delegate = self
    }
    
    override func relayoutSubViews() {
        textField.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.centerY.equalToSuperview()
            make.height.equalTo(30)
        }
    }
    
//    @objc override func clickButton() {
//        button.isSelected = !button.isSelected
//        if button.isSelected {
//            textField.isSecureTextEntry = false
//        } else {
//            textField.isSecureTextEntry = true
//        }
//    }
    
    // MARK: - UITextField
    override func textFieldChanged(sender: UITextField) {
        isEmailOk = textContent.isValidEmail
        
        tfChangedCallback?(textContent)
    }

}
